// 声明式类型的函数
function funcType(name: string, age: number) : number {
  return age
}
var ageNum: number = funcType("张三", 18)

// 函数参数不确定
function funcType2(name: string, age: number, sex?:string) : number {
  return age
}
var ageNum2: number = funcType2("张三", 18, "男")

// 函数参数的默认值
function funcType3(name: string="张三", age:number=18): number {
  return age
}
var ageNum3 = funcType3()

// 表达式类型的函数
var funcType4 = function(name: string, age: number): number {
  return age
}
funcType4("张三", 12)

var funcType5: (name:string, age:number) => number = function(name:string, age: number): number {
  return age
}
funcType5("张三", 15)

interface Ift6 {
  (name: string, age:number): number
}
var funcType6: Ift6 = function(name:string, age: number): number {
  return age
}
funcType6("张三", 18)

// 对于联合类型，可以采用重载的方式
// 让输入是number,输出也是number
// 输入是string, 输出也是string
// 即输入什么类型, 返回规定的类型
function getValue(value: number):number;
function getValue(value: string):string;
function getValue(value: string|number):string|number{
  return value
}
let a: number = getValue(1)
let b: string = getValue("ss")


export {}
